﻿@model IViewModel
@{
    var renderPrevButton = Model.MasterModel.ActionsModel.Actions.Is()
                           && Model.MasterModel.ActionsModel.Actions.Any(i => i.ActionName == Str.Actions.MovePrev);

    var renderNextButton = Model.MasterModel.ActionsModel.Actions.Is()
                           && Model.MasterModel.ActionsModel.Actions.Any(i => i.ActionName == Str.Actions.MoveNext);

    var entityModel = Model as IEntityModel<IPersistentObject, IFilter>;

    var filter = (entityModel.Is() ? entityModel.Filter : null);

    var persistentId = ((entityModel.Is() && entityModel.Item.Is()) ? entityModel.Item.IDToDisplay : string.Empty);

    var movePrev = filter.Is() && (filter.CurrentRow != 0 || filter.CurrentPage != 0)
                   ? Url.Action(Str.Actions.MovePrev, Model.MasterModel.ControllerName, new { id = persistentId })
                   : null;

    var moveNext = filter.Is() && (filter.CurrentRow + filter.TakeRows * filter.CurrentPage) < filter.TotalRows - 1
                   ? Url.Action(Str.Actions.MoveNext, Model.MasterModel.ControllerName, new { id = persistentId })
                   : null;
}
<nav>
@AddControls(

    !renderPrevButton // a sign "<" for previous detail
        ? null
        : new Anchor("paging") { new Literal("\u25C4")}
            .SetHref(movePrev)
            .SetAttribute(Attr.AccessKey, "q")
            .SetTitle(movePrev.IsNotEmpty() ? GetLocalized("Prev") + " (Shift + Alt + Q)" : null)
            .AddCssClassName(movePrev.IsNotEmpty() ? null : "disabled"),

    !renderNextButton // a sign ">" for next detail
        ? null
        : new Anchor("paging")  { new Literal("\u25BA") }
            .SetHref(moveNext)
            .SetAttribute(Attr.AccessKey, "w")
            .SetTitle(moveNext.IsNotEmpty() ? GetLocalized("Next") + " (Shift + Alt + W)" : null)
            .AddCssClassName(moveNext.IsNotEmpty() ? null : "disabled")
)
</nav>